<?php
/**
 * 登陆页面
 */

$this->title = '登录';

$this->beginBlock('headCss'); ?>

<link rel="stylesheet" href="/assets/css/pages/login.min.css">

<?php $this->endBlock('headCss'); ?>

<!-- BEGIN LOGO -->
<div class="logo">
    <h2 class="font-red">康之源原油 <!--<label class="label label-danger" style="font-size: 40%;">UB369.COM</label>--></h2>

</div>
<!-- END LOGO -->
<!-- BEGIN LOGIN -->
<div class="content">
    <!-- BEGIN LOGIN FORM -->
    <form class="login-form" action="login.html" method="post">
        <input type="hidden" name="_csrf" value="<?=Yii::$app->getRequest()->getCsrfToken();?>"/>
        <h4 class="form-title font-green">后台登录</h4>
        <div class="alert alert-danger display-hide">
            <button class="close" data-close="alert"></button>
            <span> 请输入用户名和密码. </span>
        </div>
        <div class="form-group">
            <!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
            <label class="control-label visible-ie8 visible-ie9">用户名</label>
            <input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="用户名" name="username_<?=$input_suffix;?>" /> </div>
        <div class="form-group">
            <label class="control-label visible-ie8 visible-ie9">密码</label>
            <input class="form-control form-control-solid placeholder-no-fix" type="password" autocomplete="off" placeholder="密码" name="password_<?=$input_suffix;?>" /> </div>
        <div class="form-group">
            <div class="row">
                <div class="col-md-7 col-sm-6 col-xs-6">
                    <input class="form-control form-control-solid" style="height: 50px;" type="text" placeholder="验证码" name="code" />
                </div>
                <div class="col-md-5 col-sm-6 col-xs-6">
                    <a class="pull-right" id="btnCaptcha" href="javascript:refreshCaptcha();" title="点击刷新验证码">
                        <img src="" alt="验证码"/></a>
                </div>
            </div>
            
        </div>
        <div class="form-actions">
            <button type="submit" class="btn btn-block red">登 录</button>
        </div>
    </form>
    <!-- END LOGIN FORM -->
</div>
<!--<div class="copyright"> <?/*=date('Y')*/?> © UB369.com </div>-->

<?php $this->beginBlock('footJs'); ?>
<script type="text/javascript">
    $(document).ready(function(){
        refreshCaptcha();
    });
    function refreshCaptcha(){
        var d = new Date();
        $.get(
            '/login/captcha.html?refresh=1&_='+d.getTime(),function(data){
                $('#btnCaptcha img').attr('src',data.url);
            }
        )
    }
    $('.login-form').submit(function(){
        var _this = $(this);
        var formData = _this.serialize();
        $.post(_this.attr('action'), formData, function(data){
            if(data.status === 1){
                location.href = '/login.html';
            }else{
                refreshCaptcha();
                App.alert({
                     type: 'danger', // alert's type
                     message: data.message, // alert's message
                     icon: 'fa fa-warning' // put icon class before the message
                     });
            }
        }, 'json');
        return false;
    });
</script>
<?php $this->endBlock('footJs'); ?>
